
<template>
  <a-card :bordered="false">
     <!-- 详情列表 -->
     <template>
        <div style="width: 100%">
          <h1 style="font-weight: bolder">工作台</h1>
        </div>
       <div style="width: 100%;margin-top: 26px">
         <ul style="list-style: none;">
           <li style="float:left;width:16%;text-align:center">
             <a @click="orderCenter"><img src="./img/u7193.png"  style="height:100px;width:100px;"></a>
             <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;">订单中心</p>
             <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;">订单数量：{{this.ordernumber}}</p>
           </li>
           <li style="float:left;width: 20%;text-align:center">
             <a @click="orderAfter"><img src="./img/u7193.png"  style="height:100px;width:100px;text-align:center;"></a>
             <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;text-align:center;">售后中心</p>
             <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;text-align:center;">售后数量：{{this.afternumber}}</p>
           </li>
           <li style="float:left;width: 20%;text-align:center">
             <a @click="fabricCenter"><img src="./img/u7193.png"  style="height:100px;width:100px;text-align:center;"></a>
             <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;text-align:center;">面料管理</p>
             <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;text-align:center;">面料数量：{{this.mianliaonumber}}</p>
           </li>
           <li style="float:left;width: 20%;text-align:center">
             <a @click="Customer"><img src="./img/u7193.png"  style="height:100px;width:100px;text-align:center;"></a>
             <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;text-align:center;">客户管理</p>
<!--             <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;text-align:center;">订单数量：{{this.ordernumber}}</p>-->
           </li>
           <li style="float:left;width: 20%;text-align:center">
             <a @click="Financial"><img src="./img/u7193.png"  style="height:100px;width:100px;text-align:center;"></a>
             <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;text-align:center;">财务管理</p>
<!--             <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;text-align:center;">订单数量：{{this.ordernumber}}</p>-->
           </li>
         </ul>
       </div>

<!--  <a-descriptions title="工作台" :column=5 style="margin-top: 500px">-->
<!--     <div @click="orderCenter">-->
<!--           <img src="./img/u7193.png"  style="height:100px;width:100px;align-self: center">-->
<!--         <p style="font-size: 15px;color: #2d2d2d;font-weight: bolder;margin-top: 10px;text-align:center;">订单中心</p>-->
<!--         <p style="font-size: 14px;color: #2d2d2d;margin-top: 3px;text-align:center;">订单数量：{{this.ordernumber}}</p>-->
<!--     </div>-->

<!--     <div style="text-align:center;" @click="orderAfter">-->
<!--           <img src="./img/u7189.png"  style="height:100px;width:100px">-->
<!--           <p style="margin-left: 20px;">售后中心</p>-->
<!--           <p>售后数量：{{this.afternumber}}</p>-->
<!--      </div>-->

<!--     <div >-->
<!--           <img src="./img/u7197.png"  style="height:100px;width:100px" @click="fabricCenter">-->
<!--           <p style="margin-left: 20px;">-->
<!--     面料管理-->
<!--   </p>-->
<!--      <p>面料数量：{{this.mianliaonumber}}</p>-->
<!--      </div>-->
<!--      <div >-->
<!--           <img src="./img/u7205.png"  style="height:100px;width:100px" @click="Customer">-->
<!--           <p style="margin-left: 20px;">-->
<!--     客户管理-->
<!--   </p>-->
<!--         <p></p>-->
<!--      </div>-->
<!--     <div >-->
<!--           <img src="./img/u7201.png"  style="height:100px;width:100px" @click="Financial">-->
<!--           <p style="margin-left: 20px;">-->
<!--     财务管理-->
<!--   </p>-->
<!--      <p></p>-->
<!--      </div>-->
<!--  </a-descriptions>-->
</template>


<template >
<div style="float:left;width:50%">
<h4 style="font-weight: bolder;margin-top: 56px;color: #f16215;font-size: 15px">紧急处理事件</h4>
  <a-list
    class="demo-loadmore-list"
    :loading="loading"
    item-layout="horizontal"
    :data-source="data"
  >
    <div
      v-if="showLoadingMore"
      slot="loadMore"
      :style="{ textAlign: 'center', marginTop: '12px', height: '32px', lineHeight: '32px' }"
    >
      <a-spin v-if="loadingMore" />
      <a-button v-else @click="onLoadMore(1)">
       查看更多
      </a-button>
    </div>
    <a-list-item slot="renderItem" slot-scope="item, index" >
       <!-- <a slot="actions"><span style="color:yellow"> 查看详情</span> </a> -->
      <div style="color: #9c9999;font-size: 14px;font-weight: bold;margin-right: 5px">{{index+1}}.</div>

      <div style="font-size: 14px;">{{item.eventName}}</div>
      <div style="margin-left: 16px;"><a @click="shouhoutiaozhuan(item.afterorderId,item.afterorderCode,item.orderType,item.orderSn)" style="color: #00a0e9">{{item.afterorderCode}}</a></div>
	   <div style="margin-left: 16px;font-size: 12px;">{{item.statusString}}</div>
      <div style="color:#f16215;margin-left: 16px;font-size: 12px;">{{item.createTime}}</div>

	  <div>
		  <a-dropdown>
		    <a class="ant-dropdown-link">
		      操作<a-icon type="down"/>
		    </a>
		    <a-menu slot="overlay">
		      <a-menu-item>
		        <a  @click="updateEvent(item.id,1)">完成</a>
		      </a-menu-item>
		      <a-menu-item>
		        <a  @click="updateEvent(item.id,2)">忽略</a>
		      </a-menu-item>
			  <a-menu-item>
			    <a  @click="shouhoutiaozhuan(item.afterorderId,item.afterorderCode,item.orderType,item.orderSn)">查看</a>
			  </a-menu-item>
		    </a-menu>
		  </a-dropdown>
		  &nbsp;&nbsp
	  </div>

    </a-list-item>
  </a-list>
  </div>

</template>


<template>
<div style="float:left;width:50%;padding-left: 16px" >
  <h4 style="font-weight: bolder;margin-top: 56px;color: #828080;font-size: 15px">日常处理事件</h4>
  <a-list
    class="demo-loadmore-list"
    :loading="loading"
    item-layout="horizontal"
    :data-source="data2"
  >
    <div
      v-if="showLoadingMore"
      slot="loadMore"
      :style="{ textAlign: 'center', marginTop: '12px', height: '32px', lineHeight: '32px' }"
    >
      <a-spin v-if="loadingMore" />
      <a-button v-else @click="onLoadMore(0)">
         查看更多
      </a-button>
    </div>
    <a-list-item slot="renderItem" slot-scope="item, index">
      <!-- <a slot="actions">查看详情</a> -->

      <table style="vertical-align:middle;text-align:left;width:100%">
        <tr>
          <td style="color: #9c9999;font-size: 14px;font-weight: bold;margin-right: 5px">
            {{index+1}}.
          </td>
          <td style="font-size: 14px;text-align: left" align="left">
            {{item.eventName}}
          </td>
          <td style="font-size: 14px;text-align: left;margin-left: 10px" width="120px" align="left">
            <a @click="tiaozhuan(item.orderType,item.orderSn)" style="color: #00a0e9">{{item.orderSn}}</a>
          </td>
          <td style="font-size: 12px;" width="60px" align="right">
            {{item.statusString}}
          </td>
          <td style="font-size: 12px;" width="100px" align="right">
            {{item.createTime}}
          </td>
          <td align="right" width="80px">
            <a-dropdown>
              <a class="ant-dropdown-link">
                操作<a-icon type="down"/>
              </a>
              <a-menu slot="overlay">
                <a-menu-item>
                  <a  @click="updateEvent(item.id,1)">完成</a>
                </a-menu-item>
                <a-menu-item>
                  <a  @click="updateEvent(item.id,2)">忽略</a>
                </a-menu-item>

                <a-menu-item>
                  <a  @click="tiaozhuan(item.orderType,item.orderSn)">查看</a>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
          </td>
        </tr>
      </table>


<!--      <div style="color: #9c9999;font-size: 14px;font-weight: bold;margin-right: 5px">{{index+1}}.</div>-->
<!--      <div style="font-size: 13px;">{{item.eventName}}</div>-->
<!--      <div style="margin-left: 16px;"><a @click="tiaozhuan(item.orderType,item.orderSn)">{{item.orderSn}}</a></div>-->
<!--	   <div style="margin-left: 16px;font-size: 12px;">{{item.statusString}}</div>-->
<!--     <div style="margin-left: 16px;font-size: 12px;margin-right: 2px">{{item.createTime}} </div>-->
<!--	   <div>-->
<!--	   		  <a-dropdown>-->
<!--	   		    <a class="ant-dropdown-link">-->
<!--	   		      操作<a-icon type="down"/>-->
<!--	   		    </a>-->
<!--	   		    <a-menu slot="overlay">-->
<!--	   		      <a-menu-item>-->
<!--	   		        <a  @click="updateEvent(item.id,1)">完成</a>-->
<!--	   		      </a-menu-item>-->
<!--	   		      <a-menu-item>-->
<!--	   		        <a  @click="updateEvent(item.id,2)">忽略</a>-->
<!--	   		      </a-menu-item>-->
<!--				  <a-menu-item>-->
<!--				    <a  @click="tiaozhuan(item.orderType,item.orderSn)">查看</a>-->
<!--				  </a-menu-item>-->
<!--	   		    </a-menu>-->
<!--	   		  </a-dropdown>-->
<!--	   		  &nbsp;&nbsp-->
<!--	   </div>-->
    </a-list-item>
  </a-list>
</div>
</template>

  </a-card>
</template>
<script>
import reqwest from 'reqwest';

//const fakeDataUrl = 'https://randomuser.me/api/?results=5&inc=name,gender,email,nat&noinfo';
 const fakeDataUrl = 'http://127.0.0.1:8080/mlcc/home/geteventrecrodtList?_t=1605854552&type=1';
  import JSuperQuery from '@/components/jeecg/JSuperQuery.vue';
  import JInput from '@/components/jeecg/JInput.vue';
  import {initDictOptions, filterDictText,filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import Vue from 'vue'
  import { filterObj } from '@/utils/util';
import { getAction } from '../../api/manage';

  //高级查询modal需要参数
  const superQueryFieldList=[
    {
      type: "string",
      value: "name",
      text: "用户名"
    }, {
      type: "int",
      value: "age",
      text: "年龄"
    }, {
      type: "date",
      value: "birthday",
      text: "生日"
    }
  ]
  export default {
    name: "Analysis",
    mixins:[JeecgListMixin],
    components: {
      JSuperQuery,
      JInput
    },
    data() {
      return {
        begin1:0,
         begin2:0,
        type:'',
      richangList:[],   //日常事件列表
      jingjiList:[],   //紧急事件列表
      afternumber:0,//售后订单数量
mianliaonumber:0,       //面料数量
ordernumber:0,         //订单数量
         loading: true,
      loadingMore: false,
      showLoadingMore: true,
      datasoure:[],
      data: [],
      data2:[],
        description: '单表示例列表',
        //字典数组缓存
        sexDictOptions: [],
        importExcelUrl:`${window._CONFIG['domianURL']}/test/jeecgDemo/importExcel`,
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        //列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },

          {
            title: '创建时间',
            align: "center",
            dataIndex: 'createTime'
          },

                 {
            title: '状态',
            align: "center",
            dataIndex: 'orderType',
            customRender: (orderType) => {
              //字典值替换通用方法
              if(orderType==0)
              return "面料下单";
              else if(orderType==1)
              return "个订下单";
              else  if(orderType==2)
              return "团订下单";
              else
               return "成衣下单";
            }
          },
           {
            title: '订单金额',
            align: "center",
            dataIndex: 'orderMoney'
          },


          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'},
          }
        ],
        url: {
          list: "/home/geteventrecrodtList",
           getordernumber:"/home/getordernumber",
		   updateEvent:"/home/updateEventstatus"
        },
        fieldList:superQueryFieldList
      }
    },

methods: {
	//修改时间状态
	updateEvent(id,status){
		getAction(this.url.updateEvent,{"id":id,"status":status}).then((res)=>{
		            if(res.success){
		              this.$message.success(res.message);
					  this.begin1=0;
					  this.begin2=0;
					  this.data=[],
					  this.data2=[],
					  this.getData();
		            } })
	},


     shouhoutiaozhuan(afterorderId,afterorderCode,orderType,orderSn){
	if(orderType==0){

		this.$router.push({path:'/orderCenter/AfterSaleFabric',query: {
		  id:afterorderId,
		    afterCode:afterorderCode
		}})
	}else if(orderType==1){
		this.$router.push({path:'/orderCenter/AfterSaleSingle',query: {
		  id:afterorderId,
		    afterCode:afterorderCode,
			orderSn:orderSn
		}})
	}else if(orderType==2){

		this.$router.push({path:'/orderCenter/AfterSaleGroup',query: {
		   id:afterorderId,
		   after:afterorderCode,
		   orderSn:orderSn
		}})

	}
},

	tiaozhuan(orderType,orderSn){
		if(orderType==0){

			this.$router.push({path:'/orderCenter/fabricDetail',query: {
			  order:orderSn
			}})
		}else if(orderType==1){
			this.$router.push({path:'/orderCenter/singleDetail',query: {
			  order:orderSn
			}})
		}else if(orderType==2){

			this.$router.push({path:'/orderCenter/teamDetail',query: {
			  order:orderSn
			}})

		}
	},


  //跳转到订单中心
  orderCenter(){
   this.$router.push({path:'/orderCenter/SingleOrder'})
  },

//跳到面料维护
fabricCenter(){
	this.$router.push({path:'/fabricCenter/fabric'})
},
//跳到账号管理
Customer(){
	this.$router.push({path:'/Customer/management'})
},

//跳到客户往来
Financial(){
	this.$router.push({path:'/Financial/CustomerContact'})
},
orderAfter(){
	this.$router.push({path:'/orderCenter/SingleOrder'})
},
//查询记录事件
geteventrecrodtList(type){

  getAction(this.url.list,{"type":type}).then((res)=>{
              if(res.success){

                this.$message.warning(res.message);
              } })
},

//查询订单数量的方法
   getordernumber(){
            getAction(this.url.getordernumber).then((res)=>{
              if(res.success){
              this.afternumber=res.result.afternumber;
               this.mianliaonumber=res.result.mianliaonumber;
                this.ordernumber=res.result.ordernumber;
              }else{
                this.$message.warning(res.message);
              } })
   },

//这里查紧急处理事件
   getData(callback) {

	   getAction(this.url.list,{type: 1,begin:this.begin1}).then((res)=>{
	   this.loading = false;
	    this.data = this.data.concat(res.result);
	    this.begin1=this.begin1+5;
	        });
      // reqwest({
      //   url: 'http://127.0.0.1:8080/mlcc/home/geteventrecrodtList?_t=1605854552&type=1&begin='+this.begin1,
      //   type: 'json',
      //   method: 'get',
      //   contentType: 'application/json',
      //   success: res => {

      //      this.loading = false;
      //       this.data = this.data.concat(res.result);
      //       this.begin1=this.begin1+5;
      //   },
      // });

	  getAction(this.url.list,{type: 0,begin:this.begin2}).then((res)=>{
	this.loading = false;
	 this.data2 = this.data2.concat(res.result);
	 this.begin2=this.begin2+5;
	  this.loadingMore = false;
	       });

      //    reqwest({
      //   url: 'http://127.0.0.1:8080/mlcc/home/geteventrecrodtList?_t=1605854552&type=0&begin='+this.begin2,
      //   type: 'json',
      //   method: 'get',
      //   contentType: 'application/json',
      //   success: res => {


      //      this.loading = false;
      //       this.data2 = this.data2.concat(res.result);
      //       this.begin2=this.begin2+5;
      //        this.loadingMore = false;
      //   },
      // });
    },
//这里查紧急处理事件
   getData1(callback) {
    getAction(this.url.list,{type: 1,begin:this.begin1}).then((res)=>{
    this.loading = false;
     this.data = this.data.concat(res.result);
     this.begin1=this.begin1+5;
	  this.loadingMore = false;
         });
    //   reqwest({
    //     url: 'http://127.0.0.1:8080/mlcc/home/geteventrecrodtList?_t=1605854552&type=1&begin='+this.begin1,
    //     type: 'json',
    //     method: 'get',
    //     contentType: 'application/json',
    //     success: res => {

    //        this.loading = false;
    //         this.data = this.data.concat(res.result);
    //         this.begin1=this.begin1+5;
    //     },
    //   });
    },
    //这里查日常处理事件
   getData2(callback) {
	   getAction(this.url.list,{type: 0,begin:this.begin2}).then((res)=>{
	   this.loading = false;
	    this.data2 = this.data2.concat(res.result);
	    this.begin2=this.begin2+5;
	     this.loadingMore = false;
	          });
    // reqwest({
    //     url: 'http://127.0.0.1:8080/mlcc/home/geteventrecrodtList?_t=1605854552&type=0&begin='+this.begin2,
    //     type: 'json',
    //     method: 'get',
    //     contentType: 'application/json',
    //     success: res => {


    //        this.loading = false;
    //         this.data2 = this.data2.concat(res.result);
    //         this.begin2=this.begin2+5;
    //          this.loadingMore = false;
    //     },
    //   });
    },
  //事件查看更多
    onLoadMore(i) {
      this.loadingMore = true;
      if(i==1){
  this.getData1(res => {

        this.$nextTick(() => {
          window.dispatchEvent(new Event('resize'));
        });
      });
      }else{
          this.getData2(res => {

        this.$nextTick(() => {
          window.dispatchEvent(new Event('resize'));
        });
      });
      }

    },


      //列设置更改事件
      onColSettingsChange (checkedValues) {
        var key = this.$route.name+":colsettings";
        Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
        this.settingColumns = checkedValues;
        const cols = this.defColumns.filter(item => {
          if(item.key =='rowIndex'|| item.dataIndex=='action'){
            return true
          }
          if (this.settingColumns.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns =  cols;
      },
      initColumns(){
        //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
        //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');

        var key = this.$route.name+":colsettings";
        let colSettings= Vue.ls.get(key);
        if(colSettings==null||colSettings==undefined){
          let allSettingColumns = [];
          this.defColumns.forEach(function (item,i,array ) {
            allSettingColumns.push(item.dataIndex);
          })
          this.settingColumns = allSettingColumns;
          this.columns = this.defColumns;
        }else{
          this.settingColumns = colSettings;
          const cols = this.defColumns.filter(item => {
            if(item.key =='rowIndex'|| item.dataIndex=='action'){
              return true;
            }
            if (colSettings.includes(item.dataIndex)) {
              return true;
            }
            return false;
          })
          this.columns =  cols;
        }
      }
    },
    mounted() {
    this.getData(res => {
      this.loading = false;
      this.data = res.results;
    });
  },
    created() {
      this.initColumns();
      this.getordernumber();
      //this.geteventrecrodtList(0);
      //this.geteventrecrodtList(1);
    },
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>